new Image().src="decode.png";

var start, showDecode, jumpToDecode, lastTime, lastAcc, isStarted = false;

var name

start = function() {
	//sex = $('input:radio:checked').val();
	name = $("#name").val();

	if(name){
		//$('.decode').show();
		setTimeout(jumpToDecode, 2000);
	}else{
		alert("告诉分院帽你的名字嘛");
	}

}

jumpToDecode = function(){
	var urls = [
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136059&idx=1&sn=46fcb2bb1383a7484765acb45d310c56#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136059&idx=7&sn=546dc48d47cd8f9b5bef0175c800b822#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136059&idx=3&sn=6bca0b1548ed60f046301bd25694dc75#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136059&idx=4&sn=e00f752f56f239b0bb54beee5741626d#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136059&idx=5&sn=9569175aa8081bbb9bfb0d7424407806#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136059&idx=6&sn=1f08bcea90ead7e2f3bc5717bec3b541#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136059&idx=2&sn=fd703423631ddc97ac838dae2cfac6b8#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136059&idx=8&sn=9d4d88f5fb07d57b5acce2374826c79a#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136596&idx=1&sn=7c388c45bec0b12f6641fa0eb7069be4#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136596&idx=2&sn=662051ccf6ca4d0904ed8608a77530fd#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136596&idx=3&sn=7868faa2e12c83b1679e1641314ef8d0#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136596&idx=4&sn=41e3c4766c2ae29b07150aadf616adf6#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136596&idx=5&sn=0cffd8eb618db6371b12e024bc11a58d#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136596&idx=6&sn=37ae7ebda8bdd90e26196d3f7cddf322#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136596&idx=7&sn=44037547b378ed4b9e881a536917dc3e#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136596&idx=8&sn=2bae75782571d77c8e537e3a1c39be04#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136890&idx=1&sn=cf3c24e044069f52b15ec95c0b1c6548#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136890&idx=2&sn=b37c7755f7ac144390cb63e43e1f5804#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136890&idx=3&sn=4b6f270a42d2429dda05f030d7703a72#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136890&idx=4&sn=0f7276f2c750c3672a0e36db9ab804b5#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136890&idx=5&sn=4070f15a80389b8e8513915fdc7a29f4#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136890&idx=6&sn=a6f457f2b6dfc802021271a3928b3f63#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136890&idx=7&sn=30f7cbf42695571c44b01fc785132515#rd",
	"http://mp.weixin.qq.com/s?__biz=MzA3OTE0MjQzMw==&mid=206136890&idx=8&sn=e01f0a7a403fd5076e758d877775eef4#rd",
	];
	//var jumpTo = urls[parseInt(Math.random() * urls.length)];
	var jumpTo = '#';
		jumpTo = urls[jumpToCode(name, urls.length)];
	window.location = jumpTo;
}

//$('.do').click(start);
$('#submit').click(start);


function utf82unicode(str) {
    var a = [], i = 0;
    //for (; i < str.length ;) a[i] = ("00" + str.charCodeAt(i ++).toString(16)).slice(-4);
    for (; i < str.length ;) a[i] = str.charCodeAt(i ++);
    //return "" + a.join("");
	return a;
}

function jumpToCode(name, length){
	a = utf82unicode(name)
	b = 0;
	for(i=0; i < a.length ;i++) b+=a[i];
	return b % length
}